package com.hys.authserver.auth;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.List;

/**
 * IDE: IntelliJ IDEA
 * 项目: auth-server
 * 日期: 2024/9/18 23:42:22
 * 作者: qscy
 * 功能:
 **/
@Getter
@Setter
public class SmsAuthenticationToken extends AbstractAuthenticationToken {


    private String phone;
    private String code;
    private String username;
    private String password;
    private String uid;

    private List<GrantedAuthority> authorities;

    public SmsAuthenticationToken(String phone, String code) {
        super(null);
        this.phone = phone;
        this.code = code;
    }

    public SmsAuthenticationToken(String phone, String code, List<GrantedAuthority> authorities) {
        super(authorities);
        this.phone = phone;
        this.code = code;
        this.authorities=authorities;
        setAuthenticated(true);
        super.setAuthenticated(true);
    }

    @Override
    public Object getCredentials() {
        return this.code;
    }

    @Override
    public Object getPrincipal() {
        return this.phone;
    }
}
